package com.xiangge.juanzi;

import java.util.Arrays;

public class Demo3 {
    public static void main(String[] args) {
        int[] arr = {3,12,24,36,55,68,75,88};
        Arrays.sort(arr);
        int index = -1;
        int begin = 0;
        int end = arr.length;

        while (true) {
            int mid = (begin+end)/2;
            if (arr[mid] > 24){ end = mid;
            }else if (arr[mid] < 24){
                begin = mid;
            }else {
                index = mid;
                break;
            }
        }
        System.out.println("24在数组中的索引位置："+index);
    }
}
